import os
import sys
import glob
import rdkit.Chem
from rdkit.Chem import rdMolHash
from rdkit.Chem import AllChem
import numpy as np
import argparse
import glob

parser = argparse.ArgumentParser(description="Perform a simple alchemical analysis")

parser.add_argument('-mol_file', type=str,
                    help="name of the ligand mol file")

args = parser.parse_args()
f_name=args.mol_file

charge=0
mol=rdkit.Chem.SDMolSupplier(f_name,removeHs=False)[0]

# molhashf = rdMolHash.HashFunction.names
# for i, j in molhashf.items():
#     if i=='NetCharge':
#         charge=rdMolHash.MolHash(mol, j)
charge=rdkit.Chem.GetFormalCharge(mol)

file=open('charge.dat','w')
file.write(str(charge))
file.close()

mol_name=f_name[:-6]
mol_file=mol_name+'.mol'
rdkit.Chem.MolToMolFile(mol,mol_file)
